package com.lw.vue_shop_server.controller;

import com.lw.vue_shop_server.po.Permission;
import com.lw.vue_shop_server.service.impl.MenuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MenuController {

    @Autowired
    public MenuServiceImpl menuService;

    @GetMapping("/menus")
    public Map getmenus(){
        Map<String,Object> map = new HashMap<>();
        Map<String,Object> meta = new HashMap<>();
        List<Permission> menus = menuService.getmenus();
        if(menus == null){
            meta.put("msg","获取菜单列表失败");
            meta.put("status",400);
        }else {
            map.put("data",menus);
            meta.put("msg","获取菜单列表成功");
            meta.put("status",200);
        }
        map.put("meta",meta);
        return map;
    }
}
